package com.itheima.exhandler;

import com.itheima.domain.vo.Result;
import com.itheima.exception.ClientException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 上官徵羽
 * @version 1.0
 * @since 2025-09-04 11:28
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    public Result handleException(Exception e)
    {
        e.printStackTrace();
        return Result.error("服务器异常");
    }

    @ExceptionHandler
    public Result handleClientException(ClientException e)
    {
        return Result.error(e.getMessage());
    }
}
